<?php
$arr = [1, '' => true, 24 => 'Harry Potter', '' => 'javascript', 'class' => 'English'];
reset( $arr );
while (!is_null( key( $arr ) )):
    echo "当前键名是:" . key( $arr ) . '<br>';
    echo '当前元素名是：' . current( $arr ) . '<br>';
    next( $arr );
endwhile;
echo '<hr>';

end( $arr );
while (!is_null( key( $arr ) )) {
    echo "当前键名是:" . key( $arr ) . '<br>';
    echo '当前元素名是：' . current( $arr ) . '<br>';
    prev( $arr );
}